package cn.tedu.egmvc02.controller;

import cn.tedu.egmvc02.mapper.AddressMapper;
import cn.tedu.egmvc02.pojo.dto.AddressDTO01;
import cn.tedu.egmvc02.pojo.entity.Address;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/address")
public class AddressController {
    @Autowired
    private AddressMapper addressMapper;

    @RequestMapping("/insert")
    public String insertAddress(AddressDTO01 addressDTO) {
        addressMapper.insert(addressDTO);
        return "添加成功";
    }

    @RequestMapping("/select")
    public List<Address> selectAllAddress() {
        return addressMapper.selectAll();
    }

    @RequestMapping("/delete")
    public String deleteById(Integer id) {
        addressMapper.deleteById(id);
        return "删除成功";
    }

    @RequestMapping("/update")
    public String updateById(Address address) {
        addressMapper.updateById(address);
        return "修改成功";
    }
}
